/**  
 * @Title: ScriptRunnerExample.java  
 * @Package com.blog4java.mybatis  
 * @Description: TODO(用一句话描述该文件做什么)  
 * @author suyuhao  
 * @date 2025-05-26 06:29:36   
 */
package com.blog4java.mybatis;

import java.sql.Connection;
import java.sql.DriverManager;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.junit.Test;

/**  
* @ClassName: ScriptRunnerExample  
* @Description: 使用ScriptRunner执行SQL脚本的案例 
* @author suyuhao  
* @date 2025-05-26 06:29:36
*/
public class ScriptRunnerExample {
	
    @Test
    public void testScriptRunner() {
        try {
            Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:mybatis",
                    "sa", "");
            ScriptRunner scriptRunner = new ScriptRunner(connection);
            scriptRunner.runScript(Resources.getResourceAsReader("create-table.sql"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
